package com.fecean.aabbc.netty.client.controller;

import com.fecean.aabbc.netty.client.prod7.NettyClientSender;
import com.fecean.aabbc.netty.message7.ResponseMessage;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/netty-client")
@CrossOrigin(origins = "*")
public class NettyClientController {

    @Resource
    NettyClientSender nettyClientSender;

    @GetMapping("/test")
    public String test(){
        return "NettyClientController.test";
    }

    @PostMapping("/notice")
    public String notice(
            @RequestParam(name = "tenantId") String tenantId,
            @RequestParam(name = "cinemaCode") String cinemaCode,
            @RequestParam(name = "content") String content){
        nettyClientSender.sendNotice(tenantId, cinemaCode, content);
        return "send" + System.currentTimeMillis();
    }

    @PostMapping("/request")
    public ResponseMessage request(
            @RequestParam(name = "tenantId") String tenantId,
            @RequestParam(name = "cinemaCode") String cinemaCode,
            @RequestParam(name = "content") String content){
        return nettyClientSender.sendRequest(tenantId, cinemaCode, content);
    }
}
